package com.itheima.health.jobs;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.health.service.OrderSettingService;
import com.itheima.health.utils.DateUtils;

import java.util.Calendar;

public class ClearOrderSettingJob {
    @Reference
    private OrderSettingService orderSettingService;

    /**
     * 定时删除3个月前的预约信息
     */
    public void clearOrderSetting(){
        try {
            Calendar calendar = Calendar.getInstance();
            calendar.add(Calendar.MONTH, -3);//获取3个月之前时间

            String threeMonthsAgo = DateUtils.parseDate2String(calendar.getTime());//获取3个月之前时间
//            System.out.println(DateUtils.parseDate2String(calendar.getTime()));
//            System.out.println(orderSettingService);
            orderSettingService.clearOrderSetting(threeMonthsAgo);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
